package com.myzhouye.biz.dto;/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

/**
 * @program: game01
 * @description: 攻击示例
 * @author: 那条蠢鱼
 * @create: 2025-11-11 11:27
 **/

import com.myzhouye.biz.service.PeriodicTaskExecutor;
import com.myzhouye.biz.service.RedisFactoryCacheService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * 攻击单位，继承周期性任务执行器
 */
@Schema(name = "攻击单位")
@Getter
@Setter
@Slf4j
public class AttackUnit extends PeriodicTaskExecutor {
    @Schema(description = "攻击单位ID")
    private String unitId;
    @Schema(description = "攻击力")
    private int attackPower;
    @Schema(description = "目标ID")
    private String targetId;

    public AttackUnit(String unitId, String unitName, double attackIntervalSeconds, int attackPower, RedisFactoryCacheService redisFactoryCacheService) {
        super(unitId, unitName, attackIntervalSeconds, redisFactoryCacheService);
        this.unitId = unitId;
        this.attackPower = attackPower;
    }

    @Override
    protected void onTaskComplete() {
        // 实现攻击逻辑
        performAttack();
    }

    private void performAttack() {
        if (targetId != null && !targetId.isEmpty()) {
            // 执行攻击逻辑，例如减少目标生命值等
            log.info("Unit {} attacks target {} with power {}", unitId, targetId, attackPower);
            // 可以通过事件或回调通知其他系统
        }
    }
}
